package org.zttc.itat.dome;

import java.util.Date;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.zttc.itat.model.News;
import org.zttc.itat.model.Pager;
import org.zttc.itat.model.SystemContext;
import org.zttc.itat.service.INewsService;
import org.zttc.itat.service.ISortService;
import org.zttc.itat.service.ISortTypeService;
import org.zttc.itat.service.IUserService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/beans.xml")
public class TestNews {
	@Resource(name="newsService")
	private INewsService newsService;
	@Resource(name="sortService")
	private ISortService sortService;
	@Resource(name="sortTypeService")
	private ISortTypeService sortTypeService;
	@Resource(name="userService")
	private IUserService userService;
	
	@Test
	public void addNews(){
		News n = new News();
		n.setTitle("你好啊");
		n.setCreateDate(new Date());
		n.setImg("D://a.txx");
		n.setContent("我很好,谢谢你关心啊");
		newsService.add(n,1,userService.load(1));
	}
	@Test
	public void testlisNews(){
	    SystemContext.setPageOffset(0);
	    SystemContext.setPageSize(15);
		Pager<News> pages = newsService.findBySortIdAndUId(1,null);
		for(News news:pages.getDatas()){
			System.out.println(news.getTitle());
		}
	}
	

}
